package com.hl.card.modular.packBack.controller;

import com.hl.card.common.controller.BaseController;
import com.hl.card.common.persistence.model.MarketingManage;
import com.hl.card.common.util.ResponseObject;
import com.hl.card.modular.packBack.service.IMarketingManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 营销管理控制器
 *
 * @author zhouyongbang
 * @Date 2018-06-07 10:37:08
 */
@Controller
@RequestMapping("/disMarketingManage")
public class MarketingManageController extends BaseController {

	@Autowired
	private IMarketingManageService marketingManageService;

	private String PREFIX = "/dist/disMarketingManage/";

	/**
	 * 跳转到营销管理首页
	 */
	@RequestMapping("")
	public String index() {
		return PREFIX + "disMarketingManage.html";
	}
	/**
	 * 跳转到每日签到
	 */
	@RequestMapping("/disMarketingManage")
	public String index1() {
		return PREFIX + "disMarketingManage.html";
	}
	 /**
     * 跳转到分享文章
     */
    @RequestMapping("/disMarketingManage_Article")
    public String disMarketingManageArticle() {
        return PREFIX + "disMarketingManage_Article.html";
    }                    
    /**
     * 跳转到分享文章
     */
    @RequestMapping("/disMarketingManage/disMarketingManage_Article")
    public String disMarketingManageArticle1() {
        return PREFIX + "disMarketingManage_Article.html";
    }   
	/**
	 * 修改每日签到
	 */
		@PostMapping(value = "/updataDay")
		public ResponseObject updataDay (MarketingManage marketingManage) {
			ResponseObject res = new ResponseObject();
			marketingManageService.updateById(marketingManage);
			if (null == marketingManage){
				res.setErroCode(1);
				res.setData("修改每日签到失败");
			} else {
				res.setErroCode(0);
				res.setData("修改每日签到成功");
			}
			return res;
		}
		
		/**
		 * 修改分享文章
		 */
		@PostMapping(value = "/updataArticle")
		public ResponseObject updataArticle (MarketingManage marketingManage) {
			ResponseObject res = new ResponseObject();
			marketingManageService.updateById(marketingManage);
			if (null == marketingManage){
				res.setErroCode(1);
				res.setData("修改分享文章失败");
			} else {
				res.setErroCode(0);
				res.setData("修改分享文章成功");
			}
			return res;
		}
		/**
		 * 显示每日签到
		 */
		@RequestMapping(value ="/queryDay")
		@ResponseBody
		public ResponseObject queryDay () {
			ResponseObject res = new ResponseObject();
			MarketingManage market = marketingManageService.selectMarketing();
			if (null == market){
				res.setErroCode(1);
				res.setData("查询失败");
			} else {
				res.setErroCode(0);
				res.setData(market);
			}
			System.out.println(market.toString());
			return res;
		}
		/**
		 * 显示每日分享文章
		 */
		@RequestMapping(value = "/queryArticle")
		@ResponseBody
		public ResponseObject queryArticle () {
			ResponseObject res = new ResponseObject();
			MarketingManage market = marketingManageService.selectMarketing();
			if (null == market){
				res.setErroCode(1);
				res.setData("查询失败");
			} else {
				res.setErroCode(0);
				res.setData(market);
			}
			return res;
		}
}





















